home *** CD-ROM | disk | FTP | other *** search
/ Clinical Endocrinology / Clinical Endocrinology.iso / pc / 00000000 / bookmark.dir / 00001_Script_1 next >
Text File  |  1995-11-20  |  7KB  |  285 lines

  1. on init
  2.   
  3.   global installedFolderpath, gReadBkMarks, marksList, refList
  4.   global bookmarkChoice --, gBookFlag
  5.   
  6.   --set gBookFlag = TRUE
  7.   set marksList = []
  8.   set the keyDownScript = "doAddReturn"
  9.   set bookmarkChoice = 1
  10.   
  11.   put fileIO(mNew, "read", installedFolderpath & "Bookmark.DAT") into gReadBkMarks
  12.   
  13.   if not objectp(gReadBkMarks) then
  14.     alert "Sorry. Can't find bookmarks data."
  15.   else
  16.     readBookmarks -- reads the txt file and puts it into a list
  17.     makeLinkLists -- splits this list into a reference list and link list
  18.     displayRefs -- shows the refList, item by item, in the display field
  19.     if count(marksList) > 0 then
  20.       hilite line bookmarkChoice of field "Display Field"
  21.     else
  22.       set bookmarkChoice = 0
  23.     end if
  24.     
  25.   end if
  26.   
  27. end init
  28. -----------------------------------------------------------------------------------
  29. on readBookmarks
  30.   
  31.   global gReadBkMarks, marksList
  32.   
  33.   put gReadBkMarks(mReadFile) into myText
  34.   if myText <> "" then
  35.     
  36.     put the number of lines in myText into theLines
  37.     repeat with i = 1 to theLines
  38.       
  39.       put line i of myText into myItem
  40.       add marksList, myItem
  41.       
  42.     end repeat
  43.   end if
  44.   
  45.   gReadBkMarks(mDispose)
  46.   
  47. end readBookmarks
  48. ------------------------------------------------------------------
  49. -- This handler takes marksList made from the txt file
  50. -- and splits it, using two functions, into two lists
  51. -- 
  52. on makeLinkLists
  53.   
  54.   global marksList, refList, linkList, frameList
  55.   
  56.   set refList = []
  57.   set frameList = []
  58.   set linkList = []
  59.   
  60.   repeat with i = 1 to count(marksList)
  61.     put getAt(marksList, i) into listString
  62.     
  63.     put stripRef(listString) into refString
  64.     add(refList, refString)
  65.     
  66.     put stripFrameRef(listString) into frameRefString
  67.     add(frameList, frameRefString)
  68.     
  69.     put stripPath(listString) into pathString
  70.     add(linkList, pathString)
  71.     
  72.   end repeat
  73.   
  74. end makeLinkLists
  75. -----------------------------------------------------
  76. -- This is a function!!
  77. -- To use this, use the syntax below
  78. -- put stripStart( <put a string in here> ) into newString
  79. -- where newstring is the stripped word resulting
  80. -- from this function
  81. -- StripEnd uses the same syntax.
  82.  
  83. on stripRef listString
  84.   
  85.   set the itemDelimiter to "*"
  86.   return item 1 of listString
  87.   
  88. end stripRef
  89. -----------------------------------------------------
  90. on stripFrameRef listString
  91.   
  92.   set the itemDelimiter to "*"
  93.   return item 2 of listString
  94.   
  95. end stripFrameRef
  96. -----------------------------------------------------
  97. on stripPath listString
  98.   
  99.   set the itemDelimiter to "*"
  100.   return item 3 of listString
  101.   
  102. end stripPath
  103. -----------------------------------------------------
  104. on displayRefs
  105.   
  106.   global refList
  107.   
  108.   put "" into theText
  109.   
  110.   put count(refList) into theItems
  111.   
  112.   repeat with i = 1 to theItems
  113.     
  114.     put getAt(refList, i) into theRef
  115.     if i =  1 then
  116.       put theRef after theText
  117.     else
  118.       put RETURN & theRef after theText
  119.     end if
  120.     
  121.   end repeat
  122.   
  123.   put theText into field "Display Field"
  124.   
  125. end displayRefs
  126. -----------------------------------------------------
  127. on addBookmark
  128.   
  129.   global refList, linkList, marksList, parentPath, bookmarkChoice
  130.   global frameList, gBookFrame
  131.   
  132.   put the text of field "User Field" into newRef
  133.   if newRef = "" then
  134.     alert "Please name the bookmark first."
  135.   else
  136.     add refList, newRef 
  137.     getParentPath
  138.     --insert routine for getting the frame
  139.     add frameList, gBookFrame
  140.     add linkList, parentPath
  141.     add marksList, newRef & "*" & gBookFrame  & "*" & parentPath
  142.     writeBookMarks
  143.     displayRefs
  144.     set bookmarkChoice = count(marksList)
  145.     hilite line bookmarkChoice of field "Display Field"
  146.   end if
  147.   
  148.   
  149. end addBookmark
  150. -------------------------------------------------------------
  151. on deleteBookmark
  152.   
  153.   global refList, linkList, marksList, parentPath, bookmarkChoice
  154.   global frameList
  155.   
  156.   if count(marksList) > 0 then
  157.     
  158.     deleteAt marksList, bookmarkChoice
  159.     
  160.     makeLinkLists
  161.     writeBookMarks
  162.     displayRefs
  163.     
  164.     if count(marksList) > bookmarkChoice then
  165.       set bookmarkChoice = count(marksList)
  166.       hilite line bookMarkChoice of field "Display Field"
  167.     else
  168.       set bookmarkChoice = count(marksList)
  169.       if bookmarkChoice <> 0 then hilite line bookMarkChoice of field "Display Field"
  170.     end if
  171.     
  172.   else
  173.     alert "Choose a Bookmark to delete."
  174.   end if
  175.   
  176.   
  177. end deleteBookmark
  178. -------------------------------------------------------------
  179. on getParentPath
  180.   
  181.   global parentPath, gBookFrame
  182.   
  183.   tell the stage
  184.     global parentPath, gBookFrame
  185.     put the pathname & the movieName into parentPath
  186.     put the frame into gBookFrame
  187.   end tell
  188.   
  189. end getParentPath
  190. -------------------------------------------------------------
  191. on writeBookMarks
  192.   
  193.   global refList, linkList, marksList, gWriteBkMarks, installedFolderpath
  194.   
  195.   if count(refList) <> count(linkList) then
  196.     alert "Missing some data! Try opening Bookmark.DAT" & RETURN &¼
  197. "and erasing all entries! Start from scratch."
  198.   end if
  199.   
  200.   put "" into newData
  201.   
  202.   repeat with i = 1 to count(marksList)
  203.     if i = 1 then
  204.       put getAt(marksList, i) after newData
  205.     else
  206.       put RETURN & getAt(marksList, i) after newData
  207.     end if
  208.   end repeat
  209.   
  210.   put fileIO(mNew, "write", installedFolderpath & "Bookmark.DAT") into gWriteBkMarks
  211.   if not objectP(gWriteBkMarks) then
  212.     alert "Sorry can't find bookmark data."
  213.   else
  214.     gWriteBkMarks(mWriteString, newData)
  215.     gWriteBkMarks(mDispose)
  216.   end if
  217.   
  218. end writeBookMarks
  219. -----------------------------------------------------
  220. on chooseLine
  221.   global bookmarkChoice
  222.   
  223.   put the mouseLine into bookmarkChoice
  224.   if bookmarkChoice > 0 then
  225.     hilite line bookmarkChoice of field "Display Field"
  226.   end if
  227.   
  228. end chooseLine
  229. -----------------------------------------------------
  230. on goToBookMarkOld
  231.   
  232.   global bookmarkChoice, linkList, frameList
  233.   
  234.   if bookmarkChoice > count(linkList) then
  235.     alert "Please, choose a bookmark."
  236.   else if count(linkList) < 1 then
  237.     alert "There are no bookmarks. Bookmarks must be added first."
  238.   else
  239.     put getAt(linkList, bookmarkChoice) into newPath
  240.     put getAt(frameList, bookmarkChoice) into newFrame
  241.     tell the stage
  242.       if value(newFrame) > 1 then
  243.         go frame newFrame of movie newPath
  244.         init
  245.         calcSlider
  246.         put "newFrame =" & newFrame
  247.       else
  248.         go movie newPath
  249.       end if
  250.     end tell
  251.     
  252.   end if
  253.   
  254. end goToBookMarkOld
  255. ------------------------------------------------------
  256. on doAddReturn
  257.   
  258.   if the key = RETURN then
  259.     addBookmark
  260.     dontPassEvent
  261.   end if
  262.   
  263. end doAddReturn
  264. -----------------------------------------------------
  265. on goToBookMark
  266.   
  267.   global bookmarkChoice, linkList, frameList
  268.   
  269.   if bookmarkChoice > count(linkList) then
  270.     alert "Please, choose a bookmark."
  271.   else if count(linkList) < 1 then
  272.     alert "There are no bookmarks. Bookmarks must be added first."
  273.   else
  274.     put getAt(linkList, bookmarkChoice) into newPath
  275.     put getAt(frameList, bookmarkChoice) into newFrame
  276.     tell the stage
  277.       
  278.       go movie newPath
  279.       
  280.     end tell
  281.     
  282.   end if
  283.   
  284. end goToBookMark
  285.